package com.leyou.item.client;

import com.leyou.common.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author ShenMin
 * @date 2021/7/21 17:10
 * @description
 */
@Component
@FeignClient("item-service")
public interface ItemClient {
    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> listSpuByPage(
            @RequestParam(value = "brandId", required = false) Long bid,
            @RequestParam(value = "categoryId", required = false) Long cid,
            @RequestParam(value = "id", required = false) Long spuid,
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "saleable", required = false) Boolean isSaleable
    );

    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuListBySpuIds(@RequestParam("id") Long spuId);

    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> listSpecParamBySpuId(
            @RequestParam("id") Long id,
            @RequestParam(value = "searching", required = false) Boolean isSearch
    );

    @GetMapping("/category/list")
    List<CategoryDTO> listCategoryByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping("/brand/list")
    List<BrandDTO> listBrandByIds(@RequestParam("ids") List<Long> ids);


    @GetMapping("/goods/spu/{id}")
    SpuDTO getSpuOnlyById(@PathVariable("id") Long id);

    @GetMapping("/goods/spu/detail")
    SpuDetailDTO querySpuDetailBySpuId(@RequestParam("id") Long spuId);

    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuListBySpuId(@RequestParam("id") Long spuId);

    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id") Long id);

    @GetMapping("/spec/list")
    List<SpecGroupDTO> listSpecList(@RequestParam("id") Long cid);
}
